
<html>
<head>
    <title>支付</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <script>
        window.onerror = e => {
            console.error(e)
        }

        var query = window.location.search.substring(1);
        var vars = query.split("&");

        function getParam(variable) {
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) {
                    return pair[1];
                }
            }
            return '';
        }

        if(getParam('prepay_id')=='' ){
            //window.location.href = '/Cashier/view/redirectpayment/AliH5Error.html';
        }
    </script>
    <script>
        function docReady(fn) {
            if (document.readyState === 'complete' || document.readyState === 'interactive') {
                fn()
            } else {
                document.addEventListener('DOMContentLoaded', fn);
            }
        }

        docReady(async function () {
            var isMobile = false
            if (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i)) {
                isMobile = true
            }

            if (!isMobile) {
                var containerEl = document.getElementById('desktop-web-container')
                containerEl.classList.remove('hidden')
                containerEl.classList.add('full', 'desktop-web-container')

            } else {
                var containerEl = document.getElementById('public-web-container')
                containerEl.classList.remove('hidden')
                containerEl.classList.add('full', 'public-web-container')
            }
        })


        function openAliApp() {
            var prepay_id = getParam("prepay_id");
            prepay_id =  encodeURIComponent(window.atob(decodeURIComponent(prepay_id)));

            window.location.href = "alipays://platformapi/startapp?appId=2021003126693148&page=pages/pay/pay?" + prepay_id;

            var modal = document.getElementById('modal');
            modal.style.display = "block";
        }

        function redirect() {
            var redirectUrl = getParam('redirect_url');
            if (redirectUrl == '') {
                window.history.go(-1);
            } else {
                window.location.href = decodeURIComponent(redirectUrl);
            }
        }

    </script>
    <style>
        .hidden {
            display: none;
        }

        .full {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
        }

        .public-web-container a {
            position: absolute;
            bottom: 30%;
            text-decoration: none;
            padding: 10px 30px;
            background-color: dodgerblue;
            color: white;
            width: 78%;
            margin: 10px 15px;
            text-align: center;
            border-radius: 5px;
            height: 30px;
            line-height: 30px;
        }

        .desktop-web-container p {
            position: absolute;
            top: 10%;

        }

        .tip {
            position: absolute;
            bottom: 65%;
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            padding-top: 100px;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgb(0, 0, 0);
            background-color: rgba(0, 0, 0, 0.4);
        }

        .modal-content {
            position: relative;
            background-color: #fefefe;
            margin: auto;
            padding: 0;
            border: 1px solid #888;
            width: 80%;
            box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
            -webkit-animation-name: animatetop;
            -webkit-animation-duration: 0.4s;
            animation-name: animatetop;
            animation-duration: 0.4s
        }

        @-webkit-keyframes animatetop {
            from {
                top: -300px;
                opacity: 0
            }
            to {
                top: 0;
                opacity: 1
            }
        }

        @keyframes animatetop {
            from {
                top: -300px;
                opacity: 0
            }
            to {
                top: 0;
                opacity: 1
            }
        }

        .modal-header {
            padding: 2px 5px;
        }

        .modal-body {
            padding: 2px 16px;
            margin: 15px auto 15px auto;
        }

        .center {
            text-align: center;
        }

        .desktop-web-container {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .public-web-container {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

    </style>
</head>
<body>
<div class="full">
    <div id="desktop-web-container" class="hidden">
        <p>请在手机浏览器打开网页链接</p>
    </div>
    <div id="public-web-container" class="hidden">
        <p class='tip'>即将打开支付宝支付，请点击“立即支付”按钮</p>
        <a href="javascript:" onclick="openAliApp()">立即支付</a>
    </div>
    <div id="modal" class="modal">
        <div class="modal-content" style="border-radius: 10px;">
            <div class="modal-header center" style="border-bottom: gray; border-radius: 10px 10px 0 0;">
                <h5 class="modal-body">请确认支付是否已完成?</h5>
            </div>
            <hr>
            <div class="center">
                <a style="color:red; text-decoration: none" href="javascript:redirect()"><p class="modal-body">已完成支付</p></a>
                <a style="color:gray; text-decoration: none" href="javascript:redirect()"><p class="modal-body">支付遇到问题</p></a>
            </div>

        </div>
    </div>
</div>
</body>
</html>